/**
 * <pre>
 * Copyright:		Copyright(C) 2011-2012, ketayao.com
 * Filename:		SingleThreadedExecution.ketayao.A6EaterThread.java
 * Class:			A6EaterThread
 * Date:			2012-10-17
 * Author:			<a href="mailto:ketayao@gmail.com">ketayao</a>
 * Version          1.1.0
 * Description:		
 *
 * </pre>
 **/

package SingleThreadedExecution.ketayao;

import SingleThreadedExecution.Q6.Tool;

/**
 * 
 * @author <a href="mailto:ketayao@gmail.com">ketayao</a> Version 1.1.0
 * @since 2012-10-17 下午5:15:03
 */

public class A6EaterThread extends Thread {
	private String name;
	private final Tool lefthand;
	private final Tool righthand;

	public A6EaterThread(String name, Tool lefthand, Tool righthand) {
		this.name = name;
		this.lefthand = lefthand;
		this.righthand = righthand;
	}

	public void run() {
		while (true) {
			eat();
		}
	}

	public synchronized void eat() {
		System.out.println(name + " takes up " + lefthand + " (left).");
		System.out.println(name + " takes up " + righthand + " (right).");
		System.out.println(name + " is eating now, yam yam!");
		System.out.println(name + " puts down " + righthand + " (right).");
		System.out.println(name + " puts down " + lefthand + " (left).");
	}
}
